package com.example.administrator.yuejian2.model;

import com.example.administrator.yuejian2.RetrofitListener.RetrofitListener;
import com.example.administrator.yuejian2.service.ClubService;
import com.example.administrator.yuejian2.service.CommentService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.administrator.yuejian2.other.Url.BASEURL;
import static com.example.administrator.yuejian2.other.Url.URL1;

public class CommentModel {
    private Retrofit retrofit;
    private CommentService commentService;

    public CommentModel()
    {
        retrofit = new Retrofit.Builder()
                .baseUrl(BASEURL+"comment/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        commentService = retrofit.create(CommentService.class);
    }
    public void commentlist(String picture_id, final RetrofitListener listener)
    {
        Call call=commentService.commentList(picture_id);
        call.enqueue(new Callback() {
            @Override
            public void onResponse(Call call, Response response) {
                listener.onSuccess(response.body(),1);
            }

            @Override
            public void onFailure(Call call, Throwable t) {
                listener.onFail();
            }
        });

    }
}
